<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" session="false" %><%@
include file="/WEB-INF/jspf/import.jspf" %>
<!doctype HTML>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
        <title> 车友会金币兑换-兑换信息</title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <meta name="author" content="xieyongshuang_gz zhongqingbiao_gz"/>
        <link rel="stylesheet" type="text/css" href="http://js.3conline.com/wap/pcauto/2014/touch/club/club.css">
    </head>
    <body class="g-doc">
        <!--栏目计数器/文章计数器-->
         <jsp:include page="/template/wap/common/counter.jspf">
            <jsp:param name="channel" value="7841" />
        </jsp:include>
       <%@include file="../common/intf6007.html" %>
        <!-- 公共头部 -->
        <div class="g-hd">
            <a href="http://m.pcauto.com.cn" class="header-home" title="太平洋汽车网"></a>
            <div class="header-title">
                <span class="header-title-nav">
                    <a href="${WAPROOT}/">车友会</a> 
                    &gt; <a href="${WAPROOT}/duihuan/">金币兑换</a> &gt; 兑换记录
                </span>
            </div>
        </div>
        <c:if test="${!empty pager.resultList}">
            <div id="giftConversionList">
                <c:forEach  items="${pager.resultList}" var="data">
                    <div class="g-gifelist-item">
                        <div class="gifelist-info">
                            <img src="${data.gift.giftUrl}">
                            <p class="date">于 <fmt:formatDate value="${data.createAt}" pattern="yyyy-MM-dd HH:mm"/> 兑换了</p>
                            <p class="tit">${data.gift.name}</p>
                            <div class="des"><span>消耗了</span><p class="gold">${data.gold}</p></div>
                        </div>
                        <div class="gifelist-status">
                            <c:if test="${data.status==1}">
                                <span class="yfh">已发货</span>
                            </c:if>
                            <c:if test="${data.status==0}">
                                <span class="dfh">待发货</span>
                            </c:if>
                            <c:if test="${data.status==-1}">
                                <span class="tuihui">系统退回</span>
                            </c:if>
                        </div>
                    </div>         
                </c:forEach>
            </div>
        </c:if>
        <c:if test="${empty pager.resultList}">
            <div class="g-gifelist-item-none">
                ToT 暂无兑换记录
            </div>
        </c:if>
        <c:if test="${requestScope.isMore}">
            <div class="g-btn-more" onclick="loadMore();" id="loadMore"><a href="javascript:void(0);">点击加载更多兑换记录 ></a></div>
        </c:if>
        <script type="text/javascript" src="http://js.3conline.com/wap/2013/common/js/zepto1.1.min.js" ></script>
        <script type="text/javascript">
            /*满屏功能*/
            function setHeight(){
                var Jfoot = document.querySelector(".g-footer"),
                Jbody = document.querySelector(".body");
                if (!Jfoot || !Jbody){return;}
                var webHeight = document.documentElement.clientHeight,
                JbodyHeight = Jbody.clientHeight;
                if (JbodyHeight < webHeight) {
                    Jbody.style.height = webHeight + "px";
                    Jbody.style.position = "relative";
                    Jfoot.setAttribute("style", "width:100%;position:absolute;bottom:0px;");
                }else{
                    Jfoot.style.position = "relative";
                }
            }
            window.onload = function(){
                setHeight();
            }
            var pageNo = 1;
            var pageSize=  10;
            var isLoadingMore = false;
            function getConversionPage(pageNo){
                if(pageNo!=1&&!isLoadingMore){
                    isLoadingMore = true;
                    $.getJSON("${WAPROOT}/gift/listConversionHistoryByUserId.do?req_enc=utf-8&resp_enc=utf-8&callback=?", {pageNo:pageNo,pageSize:pageSize}, function(data){
                        conversionCallBack(data);
                        isLoadingMore = false;
                    });
                }
            }
            function conversionCallBack(data){
                if(data.code==0){
                    var result = data.data;
                    var html = "";
                    for(var i=0;i<result.length;i++){
                        var d = result[i];
                        html += "<div class='g-gifelist-item'>"
                            + "<div class='gifelist-info'>"
                            +"<img src='"+ d.img +"'>"
                            +"<p class='date'>于 "+ d.time +" 兑换了</p>"
                            +"<p class='tit'>" + d.name + "</p>"
                            +"<div class='des'><span>消耗了</span><p class='gold'>"+ d.cost +"</p></div>"
                            +"</div>";
                        if(d.status == 1){
                            html += "<div class='gifelist-status'><span class='yfh'>已发货</span></div>"
                                +"</div>"; 
                        }
                        if(d.status == 0){
                            html += "<div class='gifelist-status'><span class='dfh'>待发货</span></div>"
                                +"</div>"; 
                        }
                        if(d.status == -1){
                            html += "<div class='gifelist-status'><span class='tuihui'>系统退回</span></div>"
                                +"</div>"; 
                        }
	                               
                    }
                    $("#giftConversionList").append(html);
                    setHeight();
                    pageNo = data.pageNo;
                    if(result.length < pageSize){ //请求的数据若少于6行，隐藏“加载更多”
                        $("#loadMore").hide();
                    }
                    if (Math.ceil(data.total*1.0/pageSize) == data.pageNo) {
                        $("#loadMore").hide();
                    } 
                }
            }
            function loadMore(){
                getConversionPage(pageNo+1);
            }   
        </script>
        <div id="Jfoot" class="g-footer">
            <!-- 公共底部 -->
             <%@include file="../common/intf5987.html" %>
        </div>  
    </body>
</html>